package com.health.fragment.admindoc;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.health.viewscontrols.NovaApplication;
import com.health.R;
import com.health.db.DbManager;
import com.health.fragment.NovaFragment;
import com.health.tools.SPUtil;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

/**
 * 医生管理员首页
 * 
 * @author nova
 *
 */
public class AdminDocterHome extends NovaFragment {

	private View docHomeView = null;
	private TextView tv_jgglrs;// 机构管理人数
	private TextView tv_jrxz;// 今日新增
	private TextView tv_jbrq;// 疾病人群
	private TextView tv_jrjc;// 今日监测
	private TextView tv_gxy;// 高血压
	private TextView tv_jrpg;// 今日评估
	private TextView tv_tnb;// 糖尿病
	private TextView tv_jrwz;// 今日问诊
	private TextView tv_ycf;// 孕产妇
	private TextView tv_jrjz;// 今日接诊
	private TextView tv_gwyf;// 高危孕妇
	private TextView tv_jrzz;// 今日转诊
	private DbManager dbManager = null;
	private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

	@Override
	public View findViews(LayoutInflater inflater) {
		dbManager = ((NovaApplication) getActivity().getApplication()).getDbManger();
		docHomeView = inflater.inflate(R.layout.main_doc_home, null);
		initViews(docHomeView);
		return docHomeView;
	}

	@Override
	public void setupView(View view) {
		// TODO Auto-generated method stub

	}

	@Override
	public void addListener() {
		// TODO Auto-generated method stub

	}

	@Override
	public void setData() {
		String str_currentDate = dateFormat.format(new Date());
		String str_jdr = SPUtil.getstr_jdr(getActivity());
		String str_jdrno =  SPUtil.getStr_jdrno(getActivity());
		tv_jgglrs.setText(String.valueOf(dbManager.getCountByJDR(str_jdrno)));
		tv_jrxz.setText(String.valueOf(dbManager.getCountByJDRCurrentDate(str_jdrno, str_currentDate)));
		// 疾病人群
		tv_jbrq.setText(String.valueOf(dbManager.getCountByJDRJBType(str_jdrno)));
		// 今日监测
		tv_jrjc.setText(String.valueOf(dbManager.getCountByJDRCurrentDate(str_jdrno, str_currentDate)));
		// 高血压
		tv_gxy.setText(String.valueOf(dbManager.getCountByJDRType(str_jdrno, "6")));
		// 糖尿病
		tv_tnb.setText(String.valueOf(dbManager.getCountByJDRType(str_jdrno, "7")));
		// 孕产妇
		tv_ycf.setText(String.valueOf(dbManager.getCountByJDRType(str_jdrno, "3")));
		// //今日评测
		// tv_jrpg.setText("5");
		// //今日问诊
		// tv_jrwz.setText("7");
		// // 今日接诊
		// tv_jrjz.setText("9");
		// //高危孕妇
		// tv_gwyf.setText("1");
		// //今日转诊
		// tv_jrzz.setText("2");

	}

	/**
	 * 初始化布局
	 * 
	 * @author 王婷婷
	 * @date 2017年2月10日 下午3:17:44
	 */
	private void initViews(View v) {
		tv_jgglrs = (TextView) v.findViewById(R.id.tv_jgglrs);
		tv_jrxz = (TextView) v.findViewById(R.id.tv_jrxz);// 今日新增
		tv_jbrq = (TextView) v.findViewById(R.id.tv_jbrq);// 疾病人群
		tv_jrjc = (TextView) v.findViewById(R.id.tv_jrjc);// 今日监测
		tv_gxy = (TextView) v.findViewById(R.id.tv_gxy);// 高血压
		tv_jrpg = (TextView) v.findViewById(R.id.tv_jrpg);// 今日评估
		tv_tnb = (TextView) v.findViewById(R.id.tv_tnb);// 糖尿病
		tv_jrwz = (TextView) v.findViewById(R.id.tv_jrwz);// 今日问诊
		tv_ycf = (TextView) v.findViewById(R.id.tv_ycf);// 孕产妇
		tv_jrjz = (TextView) v.findViewById(R.id.tv_jrjz);// 今日接诊
		tv_gwyf = (TextView) v.findViewById(R.id.tv_gwyf);// 高危孕妇
		tv_jrzz = (TextView) v.findViewById(R.id.tv_jrzz);// 今日转诊
	}

	@Override
	public void setXueYang(String xueYang) {

	}
}
